package com.linjm.gmalllist.controller;

import com.linjm.bean.*;
import com.linjm.service.ListService;
import com.linjm.service.ManageService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;



import java.io.IOException;
import java.util.List;


@Controller
@CrossOrigin
public class ListController {
    @DubboReference
    private ListService listService;
    @DubboReference
    private ManageService manageService;
    @RequestMapping("list.html")
    public String getList(SkuLsParams skuLsParams, Model model) throws IOException {
        SkuLsResult skuLsResult = listService.search(skuLsParams);
        List<SkuLsInfo> skuLsInfoList = skuLsResult.getSkuLsInfoList();
        model.addAttribute("skuLsInfoList",skuLsInfoList);
        // 从结果中取出平台属性值列表
        List<String> attrValueIdList = skuLsResult.getAttrValueIdList();

        // 通过平台属性值Id 查找平台属性名称，平台属性值名称
        List<BaseAttrInfo> baseAttrInfoList =  manageService.getAttrList(attrValueIdList);
        model.addAttribute("baseAttrInfoList",baseAttrInfoList);
        return "list";
    }



}
